<template>
  <div id="app">
    <el-container>
      <el-header id="head" :height="'5vh'">
        <NavMenu :user="user" @exit="exit"></NavMenu>
      </el-header>
      <el-main id="main">
        <router-view @login="login" :user="user"></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
  import NavMenu from "./components/NavMenu";
  export default {
    components: {NavMenu},
    data() {
      return {
        user: null
      }
    },
    methods: {
      login(user) {
        this.user = user
        window.localStorage.setItem('login', user)
      },
      exit() {
        this.user = null
        window.localStorage.removeItem('login')
        this.$router.push('/login')
      }
    },
    created() {
      this.user = window.localStorage.getItem('login')
    }
  }
</script>

<style>
  #app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
  }
  body {
    margin: 0;
  }
  #head {
    padding: 0;
    margin: 0;
  }
  #main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 95vh;
    padding: 0;
  }

</style>
